package com.pengshun.modules.common;

import com.fasterxml.jackson.annotation.JsonView;

import java.io.Serializable;

/**
 * @author
 */
public class BaseResult<T> implements Serializable {

    private Integer code;

    private String errors;

    private Long total;

    private String jwtToken;

    /**
     * 是否有更多数据,小程序使用
     */
    private Boolean hasMore;

    private T data;

    private Object common;


    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public String getErrors() {
        return errors;
    }

    public void setErrors(String errors) {
        this.errors = errors;
    }


    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public String getJwtToken() {
        return jwtToken;
    }

    public void setJwtToken(String jwtToken) {
        this.jwtToken = jwtToken;
    }

    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public Boolean getHasMore() {
        return hasMore;
    }

    public void setHasMore(Boolean hasMore) {
        this.hasMore = hasMore;
    }

    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public Object getCommon() {
        return common;
    }

    public void setCommon(Object common) {
        this.common = common;
    }


    @JsonView({ReslutView.aView.class, ReslutView.bView.class, ReslutView.cView.class, ReslutView.dView.class, ReslutView.eView.class, ReslutView.fView.class, ReslutView.gView.class})
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    public BaseResult() {
    }


    public BaseResult(Integer code, String errors) {
        this.errors = errors;
        this.code = code;
    }

    public BaseResult(Integer code, String errors, T data, Boolean hasMore) {
        this.errors = errors;
        this.code = code;
        this.data=data;
        this.hasMore=hasMore;
    }

    public BaseResult(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public BaseResult(Integer code, String jwtToken, T data) {
        this.code = code;
        this.jwtToken = jwtToken;
        this.data = data;
    }

    public BaseResult(Integer code) {
        this.code = code;
    }

    public BaseResult(String errors) {
        this.code =1;
        this.errors = errors;
    }

    public BaseResult(T data) {
        this.code =0;
        this.data = data;
    }
}
